package mo.offer_version2;

import java.math.BigInteger;
import java.util.Arrays;

public class L14_2 {

    public int cuttingRope(int n) {
        BigInteger[] dp = new BigInteger[n+1];
        Arrays.fill(dp, BigInteger.ONE);

        for (int i = 3; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                dp[i] = dp[i].max(dp[i-j].max(BigInteger.valueOf(i-j)).multiply(BigInteger.valueOf(j)));
            }
        }

        return dp[n].mod(BigInteger.valueOf(1000000007)).intValue();
    }

    public static void main(String[] args) {
        L14_2 test = new L14_2();
        System.out.println(test.cuttingRope(120));
    }
}
